"""VueDjangoFrameWorkShop URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include

from VueDjangoFrameWorkShop.settings import MEDIA_ROOT
from django.views.static import serve


# from django.urls import path
from goods.views import GoodsListViewSet, CategoryViewset, BannerViewset, IndexCategoryViewset, HotSearchsViewset

from rest_framework.routers import DefaultRouter
from rest_framework.authtoken import views
# from rest_framework_jwt.views import obtain_jwt_token

router = DefaultRouter()

router.register(r'goods', GoodsListViewSet, basename="goods")

# 配置Category的url
router.register(r'categories', CategoryViewset, basename="categories")
# 首页banner轮播图url
router.register(r'banners', BannerViewset, basename="banners")

# 首页系列商品展示url
router.register(r'indexgoods', IndexCategoryViewset, basename="indexgoods")
router.register(r'hotsearchs', HotSearchsViewset, basename="hotsearchs")

from tyadmin_api.views import AdminIndexView
urlpatterns = [
    re_path('^', include(router.urls)),
    path('api-auth/', include('rest_framework.urls')),
    # path(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}),
    re_path('media/(?P<path>.*)', serve, {"document_root": MEDIA_ROOT}),

    path('admin/', admin.site.urls),
    re_path('^xadmin/.*', AdminIndexView.as_view()),
    path('api/xadmin/v1/', include('tyadmin_api.urls')),
]
